| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Camera.h
1 // Camera.h
3 //
5
6 namespace nkGraphics
7 {
13 class Camera : public Node
14 {
15 public :
16
17 // Getters
21 const Frustum& getFrustum () ;
25 nkMemory::StringView getName () const ;
29 PROJECTION_TYPE getProjectionType () const ;
33 float getPerspectiveFov () const ;
37 float getPerspectiveAspectRatio () const ;
41 float getPerspectiveOffCenterFovLeft () const ;
45 float getPerspectiveOffCenterFovRight () const ;
49 float getPerspectiveOffCenterFovTop () const ;
53 float getPerspectiveOffCenterFovBottom () const ;
57 float getOrthographicHeight () const ;
61 float getOrthographicAspectRatio () const ;
65 float getNear () const ;
69 float getFar () const ;
73 bool getAutoUpdateOnContextSwitch () const ;
77 bool getHidden () const ;
81 const nkMaths::Matrix& getViewMatrix () const ;
85 const nkMaths::Matrix& getProjectionMatrix () const ;
89 nkMaths::Matrix getViewProjMatrix () const ;
90
91 // Setters
95 virtual void setPositionRelative (const nkMaths::Vector& value) override ;
99 virtual void setPositionAbsolute (const nkMaths::Vector& value) override ;
103 virtual void translateRelative (const nkMaths::Vector& value) override ;
107 virtual void translateAbsolute (const nkMaths::Vector& value) override ;
111 virtual void setOrientationRelative (const nkMaths::Quaternion& value) override ;
115 virtual void setOrientationAbsolute (const nkMaths::Quaternion& value) override ;
119 virtual void rotateRelative (const nkMaths::Quaternion& value) override ;
123 virtual void rotateAbsolute (const nkMaths::Quaternion& value) override ;
127 virtual void setScaleRelative (const nkMaths::Vector& value) override ;
131 virtual void setScaleAbsolute (const nkMaths::Vector& value) override ;
135 virtual void applyScale (const nkMaths::Vector& value) override ;
143 void setName (nkMemory::StringView name) ;
153 void setAsPerspective (float fovRadian, float aspectRatioWidthOverHeight) ;
165 void setAsPerspectiveOffCenter (float fovLeftRadian, float fovRightRadian, float fovTopRadian, float fovBottomRadian) ;
175 void setAsOrthographic (float height, float aspectRatioWidthOverHeight) ;
182 void setRange (float near, float far) ;
189 void prepareForContext (RenderContext* context) ;
199 void setAutoUpdateOnContextSwitch (bool value) ;
207 void setHidden (bool value) ;
208
209 // Updates
213 void updateViewMatrix () ;
217 void updateProjectionMatrix () ;
224 void lookAt (const nkMaths::Vector& point, const nkMaths::Vector& enforcedUp = nkMaths::Vector(0, 0, 0, 0)) ;
225
226 // Utilities
235 void getNearPlanePoints (nkMaths::Vector& a, nkMaths::Vector& b, nkMaths::Vector& c, nkMaths::Vector& d) ;
244 void getFarPlanePoints (nkMaths::Vector& a, nkMaths::Vector& b, nkMaths::Vector& c, nkMaths::Vector& d) ;
254 void getFrustumCornersDirectionsWorld (nkMaths::Vector& a, nkMaths::Vector& b, nkMaths::Vector& c, nkMaths::Vector& d) ;
264 void getFrustumCornersDirectionsView (nkMaths::Vector& a, nkMaths::Vector& b, nkMaths::Vector& c, nkMaths::Vector& d) ;
265
266 // Raycast
278 nkMaths::Vector getDirectionAtPixelWorld (int x, int y, RenderContext* fromContext = nullptr) ;
286 nkMaths::Vector getDirectionAtScreenCoordWorld (float x, float y) ;
298 nkMaths::Vector getDirectionAtPixelView (int x, int y, RenderContext* fromContext = nullptr) ;
306 nkMaths::Vector getDirectionAtScreenCoordView (float x, float y) ;
307
308 // Import / Export
309 virtual void exportClassToTree (nkExport::Node* rootNode) override ;
310 virtual void importClassFromTree (nkExport::Node* rootNode) override ;
311
312 public :
313
314 // Statics
322 static nkMemory::UniquePtr<Camera> create (System* system = nullptr) ;
323 } ;
324 }
nkGraphics::Camera::getDirectionAtPixelView
nkMaths::Vector getDirectionAtPixelView(int x, int y, RenderContext *fromContext=nullptr)
nkGraphics::Camera::setAutoUpdateOnContextSwitch
void setAutoUpdateOnContextSwitch(bool value)
nkGraphics::Camera::lookAt
void lookAt(const nkMaths::Vector &point, const nkMaths::Vector &enforcedUp=nkMaths::Vector(0, 0, 0, 0))
nkGraphics::Camera::getOrthographicHeight
float getOrthographicHeight() const
nkGraphics::Camera::setHidden
void setHidden(bool value)
nkGraphics::Camera::getProjectionMatrix
const nkMaths::Matrix & getProjectionMatrix() const
nkGraphics::Camera::setPositionAbsolute
virtual void setPositionAbsolute(const nkMaths::Vector &value) override
nkGraphics::System
Main interface with the component system.
Definition: System.h:14
nkGraphics::Camera::updateViewMatrix
void updateViewMatrix()
nkGraphics::Camera::setAsPerspectiveOffCenter
void setAsPerspectiveOffCenter(float fovLeftRadian, float fovRightRadian, float fovTopRadian, float fovBottomRadian)
nkGraphics::Camera::exportClassToTree
virtual void exportClassToTree(nkExport::Node *rootNode) override
nkGraphics::Camera
Offers all controls to model a camera.
Definition: Camera.h:14
nkGraphics::Camera::create
static nkMemory::UniquePtr< Camera > create(System *system=nullptr)
nkGraphics::Camera::rotateRelative
virtual void rotateRelative(const nkMaths::Quaternion &value) override
nkGraphics::Camera::getFar
float getFar() const
nkGraphics::Camera::getViewMatrix
const nkMaths::Matrix & getViewMatrix() const
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkGraphics::Camera::getPerspectiveAspectRatio
float getPerspectiveAspectRatio() const
nkGraphics::Camera::getFarPlanePoints
void getFarPlanePoints(nkMaths::Vector &a, nkMaths::Vector &b, nkMaths::Vector &c, nkMaths::Vector &d)
nkGraphics::Camera::getPerspectiveOffCenterFovLeft
float getPerspectiveOffCenterFovLeft() const
nkGraphics::Camera::getAutoUpdateOnContextSwitch
bool getAutoUpdateOnContextSwitch() const
nkGraphics::Camera::getNearPlanePoints
void getNearPlanePoints(nkMaths::Vector &a, nkMaths::Vector &b, nkMaths::Vector &c, nkMaths::Vector &d)
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkGraphics::RenderContext
A rendering context, attached to a window or an offscreen texture.
Definition: RenderContext.h:14
nkGraphics::Camera::getFrustum
const Frustum & getFrustum()
nkGraphics::Camera::translateRelative
virtual void translateRelative(const nkMaths::Vector &value) override
nkGraphics::Camera::getPerspectiveOffCenterFovRight
float getPerspectiveOffCenterFovRight() const
nkGraphics::Camera::getDirectionAtScreenCoordView
nkMaths::Vector getDirectionAtScreenCoordView(float x, float y)
nkGraphics::Camera::translateAbsolute
virtual void translateAbsolute(const nkMaths::Vector &value) override
nkGraphics::Camera::applyScale
virtual void applyScale(const nkMaths::Vector &value) override
nkGraphics::Camera::getPerspectiveOffCenterFovTop
float getPerspectiveOffCenterFovTop() const
nkGraphics::Camera::prepareForContext
void prepareForContext(RenderContext *context)
nkGraphics::Camera::getDirectionAtPixelWorld
nkMaths::Vector getDirectionAtPixelWorld(int x, int y, RenderContext *fromContext=nullptr)
nkGraphics::Camera::getDirectionAtScreenCoordWorld
nkMaths::Vector getDirectionAtScreenCoordWorld(float x, float y)
nkGraphics::Camera::getName
nkMemory::StringView getName() const
nkExport::Node
A node in the tree structure representing the data to export / import.
Definition: Node.h:42
nkGraphics::Camera::rotateAbsolute
virtual void rotateAbsolute(const nkMaths::Quaternion &value) override
nkGraphics::Camera::importClassFromTree
virtual void importClassFromTree(nkExport::Node *rootNode) override
nkMemory::UniquePtr
Smart pointer owning the object instance it encapsulates.
Definition: UniquePtr.h:17
nkGraphics::Camera::updateProjectionMatrix
void updateProjectionMatrix()
nkGraphics::Camera::getHidden
bool getHidden() const
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkGraphics::Camera::getFrustumCornersDirectionsWorld
void getFrustumCornersDirectionsWorld(nkMaths::Vector &a, nkMaths::Vector &b, nkMaths::Vector &c, nkMaths::Vector &d)
nkGraphics::Camera::getOrthographicAspectRatio
float getOrthographicAspectRatio() const
nkGraphics::Camera::setAsOrthographic
void setAsOrthographic(float height, float aspectRatioWidthOverHeight)
nkGraphics::Camera::setPositionRelative
virtual void setPositionRelative(const nkMaths::Vector &value) override
nkGraphics::Camera::setRange
void setRange(float near, float far)
nkGraphics::Camera::setScaleRelative
virtual void setScaleRelative(const nkMaths::Vector &value) override
nkGraphics::Camera::getViewProjMatrix
nkMaths::Matrix getViewProjMatrix() const
nkGraphics::Camera::setAsPerspective
void setAsPerspective(float fovRadian, float aspectRatioWidthOverHeight)
nkGraphics::Frustum
Defines a frustum.
Definition: Frustum.h:16
nkGraphics::Camera::getNear
float getNear() const
nkGraphics::Camera::setScaleAbsolute
virtual void setScaleAbsolute(const nkMaths::Vector &value) override
nkGraphics::Camera::setName
void setName(nkMemory::StringView name)
nkGraphics::Camera::getProjectionType
PROJECTION_TYPE getProjectionType() const
nkGraphics::Node
Represents a node in a scene graph.
Definition: Node.h:16
nkGraphics
Encompasses all API of component NilkinsGraphics.
Definition: BoundingBox.h:7
nkGraphics::Camera::getPerspectiveOffCenterFovBottom
float getPerspectiveOffCenterFovBottom() const
nkGraphics::Camera::setOrientationAbsolute
virtual void setOrientationAbsolute(const nkMaths::Quaternion &value) override
nkGraphics::PROJECTION_TYPE
PROJECTION_TYPE
Lists all possible projection types for a camera.
Definition: ProjectionType.h:12
nkGraphics::Camera::getFrustumCornersDirectionsView
void getFrustumCornersDirectionsView(nkMaths::Vector &a, nkMaths::Vector &b, nkMaths::Vector &c, nkMaths::Vector &d)
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkGraphics::Camera::setOrientationRelative
virtual void setOrientationRelative(const nkMaths::Quaternion &value) override
nkGraphics::Camera::getPerspectiveFov
float getPerspectiveFov() const